<template>
  <div class="container">
    <div class="banner-container">
      <el-image
          src="/breed/introduction_background.jpg"
          alt="平台介绍背景图"
          class="banner-image"
      />
    </div>

    <div class="content-wrapper">
      <!-- 左侧导航栏 -->
      <div class="nav-container">
        <el-card class="nav-card">
          <div class="nav-header">
            <h1 class="nav-title">平台概况</h1>
          </div>
          <el-menu
              router
              :default-active="activeIndex"
              class="nav-menu"
              mode="vertical"
              @select="handleSelect"
          >
            <el-menu-item index="/PlatformIntroduction/Introduction">
              <template #title>
                <span class="menu-title">平台介绍</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/PlatformIntroduction/ResearchIntroduction">
              <template #title>
                <span class="menu-title">科研条件</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/PlatformIntroduction/MemberIntroduction">
              <template #title>
                <span class="menu-title">团队成员</span>
              </template>
            </el-menu-item>
            <el-menu-item index="/PlatformIntroduction/ResearchResult">
              <template #title>
                <span class="menu-title">科研成果</span>
              </template>
            </el-menu-item>
          </el-menu>
        </el-card>
      </div>

      <!-- 右侧内容区 -->
      <div class="main-content">
        <router-view />
      </div>
    </div>
  </div>
</template>

<script>
import { ref } from 'vue';
import { ElDivider } from 'element-plus';

export default {
  components: {
    ElDivider
  },
  setup() {
    const activeIndex = ref('/');

    const handleSelect = (index) => {
      activeIndex.value = index;
      console.log('Selected index:', index);
    };

    return {
      activeIndex,
      handleSelect
    };
  }
};
</script>

<style scoped>
/* 整体布局 */
.container {
  min-height: 100vh;
  min-width: 100%;
  padding-bottom: 30px;
}

.banner-container {
  width: 100%;
  max-height: 300px;
  overflow: hidden;
  margin-bottom: 2rem;
}

.banner-image {
  width: 100%;
  height: auto;
  object-fit: cover;
}

.content-wrapper {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: 80%;
  margin: 0 auto;
}

@media (min-width: 1024px) {
  .content-wrapper {
    flex-direction: row;
    width: 100%;
    padding-left: 10%; /* 左侧整体留白10% */
    padding-right: 10%; /* 右侧整体留白10% */
    box-sizing: border-box;
  }
}

/* 左侧导航样式 */
.nav-container {
  width: 100%;
}

@media (min-width: 1024px) {
  .nav-container {
    width: 19rem;
    flex-shrink: 0;
    padding-right: 2.5rem; /* 导航与内容之间的间距 */
  }
}

.nav-card {
  height: fit-content;
  border-radius: 0;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
  padding: 2rem;
}

.nav-header {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 3px solid #13675b;
}

.nav-title {
  font-size: 1.5rem;
  font-weight: bold;
  color: #13675b;
}

.nav-menu {
  font-size: 1.875rem;
}

.el-menu-item {
  font-size: 1.875rem;
  height: 3.75rem;
  line-height: 3.75rem;
}

.el-menu-item span {
  font-size: 1.875rem;
}

.menu-title {
  font-size: 1.125rem;
}

/* 右侧内容区 */
.main-content {
  flex: 1;
}

/* 响应式调整 */
@media (max-width: 1024px) {
  .nav-menu,
  .el-menu-item,
  .el-menu-item span {
    font-size: 1.875rem;
  }
}

@media (max-width: 768px) {
  .nav-menu,
  .el-menu-item,
  .el-menu-item span {
    font-size: 1.875rem;
  }
}
</style>